package me.victor.hotfix

import android.Manifest
import android.content.pm.PackageInfo
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
            val checkPermission = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
            if (checkPermission != PackageInfo.REQUESTED_PERMISSION_GRANTED)
                requestPermissions(arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), 0)
        }
        val button = findViewById<Button>(R.id.fix)
        button.setOnClickListener {
            HotFixEngine.copyDexFileToAppAndFix(this, "classes.dex", true)
        }
        val show = findViewById<Button>(R.id.show)
        show.setOnClickListener {
            val msg = MessageShow()
            msg.show()
        }

    }


}